<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px"><head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="css/ui-base.css">
    <link rel="stylesheet" href="css/ui-box.css">
	<link rel="stylesheet" href="css/project/style.css">
	<link rel="stylesheet" href="css/zv_common.css">
    <script src="js/zy_control.js"></script>
	<script src="js/zy_json.js"></script>
    <script src="js/main.js"></script>
	<script src="js/init.js"></script>
	<script src="js/airport.js"></script>
	<script src="js/talkingdata.js"></script>
	<script src="js/common.js"></script>
	<style>

	.allbline{ border-bottom:1px solid #dbdbdb;}
	td{ height:2.8em; line-height:2.8em; padding:0}
	.odd{ background:#ffffff}
	</style>
</head>
<body class="um-vp" ontouchstart id="body">
<div class="ub ub-ver">

<div id="ranking_content">
	  <div id='date_time'  style=" line-height:2.5em; color:#06F; background-color:#e8e8e8; height:2.5em;   width:100%; text-align:center;  font-size:1.2em;  " >
  </div>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="33%"  align="center" valign="middle" class="allbline"><span class="ub-f1 ">排名</span></td>
    <td width="33%" align="center" valign="middle" class="allbline"><span class="ub-f1 ">航站名</span></td>
    <td width="33%" align="center" valign="middle" class="allbline"><span class="ub-f1 ">系数</span></td>
  </tr>
	<tr>
		<td colspan="3" align="center" id="terminal_ranking">	

		</td>
	</tr>
</table>	
	
</div>

</div>
</body>
<script>
zy_init();
window.uexOnload=function(type){
	Loading(0);
	if(!type){
		uexWindow.setBounce("0");
	}
	//uexEMM.setEvent("1","{'航站自助排名':'航站自助排名'}");
	IC.talkingDataCount("航站自助排名","0015");
	terminal_ranking();
}

function terminal_ranking(){
            var oDate = new Date();
              var toyer  = String(oDate.getFullYear());   
              var tomos  = String(oDate.getMonth()+1);
              var today  = String(oDate.getDate()); 
              var nDate= new Date(toyer,tomos,today-1);
               tomos = tomos < 10 ? ('0' + tomos) : tomos; 
               today = today < 10 ? ('0' + today) : today; 
               var todays=toyer+"/"+tomos+"/"+today;
			 var date=new Date(todays);
             var day=date.getDay();
             function showdate(n,s) 
        { 
           if(n===0)(
               n=7
           )
           // alert(date-0-(s-(6-n)));
            var uom = new Date(date-0-(s-(6-n))*86400000); 
            var tomos1=uom.getMonth()+1;
            var todays= uom.getDate();
            if(tomos1<10){
                tomos1="0"+Number(tomos1)
            }
            if(todays<10){
                todays="0"+Number(todays);
            }
            uom = uom.getFullYear() + "-" +(""+tomos1) + "-" + ""+todays; 
            return uom; 
        }
       // console.log(showdate(day,14)) ;
        var start_date=showdate(day,14);
        var end_date=showdate(day,8);
        zizu(end_date,start_date);
        $$("date_time").innerHTML=start_date+" 至 "+ end_date;  
	    localStorage.setItem("terminal_type","1");
			// console.log(selfhelp_ranking_url+"?RequestKey="+RequestKey);
			//$.getJSON(selfhelp_ranking_url+"?RequestKey="+RequestKey,function(json){
			    // console.log(JSON.stringify(json));
			 	/* localStorage.setItem("terminal_type","2");
			 	var start_date=json[0].start_date;
			 	var end_date=json[0].end_date;
			 	zizu(end_date,start_date);
			 	 $$("date_time").innerHTML=json[0].start_date+" 至 "+ json[0].end_date;  
				for(var i=0;i<json.length;i++)	
				 {
				 	if(i==0)
					{
					 $$("date_time").innerHTML=json[i].start_date+" 至 "+ json[i].end_date;	
					}
					var s= i+1;
					var ranking='&nbsp;'
					if(s<=3)
					{
						ranking='<div  style="line-height:0.8em" ><img src="images/'+s+'.png" width="15%"/></div>'
					}
					else{
						ranking=s
					}
					var fff=''
					if(i%2==0)
					{
						fff='class="odd"';
					}
					var avgscore=json[i].avgscore
					if(avgscore=="" || avgscore=="undefined" ||   avgscore==undefined)
					{
						avgscore=0
					}
					else
					{
						//avgscore=parseFloat(avgscore)+1
						avgscore=parseFloat(avgscore)*100;
						avgscore=parseFloat(avgscore).toFixed(2);
						//avgscore=avgscore-1
						
						//alert(avgscore)
						//avgscore=avgscore+"%"
					}
					strx += '<table width="100%" border="0" cellspacing="0" cellpadding="0">'
				  	strx += '<tr '+fff+'>'
					strx += '<td align="center" width="33%;"  class="allbline">'+ranking+'</td>'
					strx += '<td align="center" width="33%" class="allbline">'+json[i].airportName+'</td>'
					strx += '<td align="center" width="33%" class="allbline">'+avgscore+'%</td>'
					strx += '</tr>'
				 	strx += '</table>'
				 }
				 $$("terminal_ranking").innerHTML=strx;
				 Loading(-1);*/
			//})
			
			//setTimeout('ranking_stop()',120000);
}	
function ranking_stop()
{
	var terminal_type=localStorage.getItem("terminal_type")
	if(terminal_type=='1')
	{
		var height=$$("body").offsetHeight
		document.getElementById("ranking_content").innerHTML='<div  style="width:100%; text-align:center;line-height:'+height+'px;"><img src="images/stop.png" style="width:40%; text-align:center;"></div>'
		Loading(-1);
	}
}
function zizu(end_date,start_date){
    var strx = "";
    //http://127.0.0.1:8080/yddfMAS/querySiteCallCount?endDate='+end_date+'&startDate='+start_date
    console.log(h_yddfUrl+'yddfMAS/querySiteCallCount?endDate='+end_date+'&startDate='+start_date)
     $.getJSON(h_yddfUrl+'yddfMAS/querySiteCallCount?endDate='+end_date+'&startDate='+start_date,function(json){
         localStorage.setItem("terminal_type","2");
         console.log(JSON.stringify(json));
         json=json.return.aptChnlPsgNumList;
         for(var i=0;i<json.length;i++) 
                 {
                    var s= i+1;
                    var ranking='&nbsp;'
                    if(s<=3)
                    {
                        ranking='<div  style="line-height:0.8em" ><img src="images/'+s+'.png" width="15%"/></div>';
                    }
                    else{
                        ranking=s
                    }
                    var fff=''
                    if(i%2==0)
                    {
                        fff='class="odd"';
                    }
                    var avgscore=json[i].aptPsgPct;
                    if(avgscore=="" || avgscore=="undefined" ||   avgscore==undefined)
                    {
                        avgscore=0
                    }
                    else
                    {  
                        if(typeof(avgscore)=="object"){
                             avgscore=0
                        }else{
                            
                        }
                        //avgscore=parseFloat(avgscore)+1
                       // avgscore=parseFloat(avgscore)*100;
                        //avgscore=parseFloat(avgscore).toFixed(2);
                        //avgscore=avgscore-1
                        
                        //alert(avgscore)
                        //avgscore=avgscore+"%"
                    }
                    var airname=json[i].airportFrom;
                    for(j=0;j<airportjs.data.items.length;j++){
                        if(airname==airportjs.data.items[j].IATACode){
                            airname=airportjs.data.items[j].FullName;
                        }
                    }
                    strx += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
                    strx += '<tr '+fff+'>';
                    strx += '<td align="center" width="33%;"  class="allbline">'+ranking+'</td>';
                    strx += '<td align="center" width="33%" class="allbline">'+airname+'</td>';
                    strx += '<td align="center" width="33%" class="allbline">'+avgscore+'</td>';
                    strx += '</tr>';
                    strx += '</table>';
                 }
                  $$("terminal_ranking").innerHTML=strx;
                 Loading(-1);
     })
   setTimeout('ranking_stop()',120000);
}
</script>
</html>
